<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='global-property-'>/**
</span> * @ignore
 * abstract class for tag and text, comment .. etc
 * @author yiminghe@gmail.com
 */
KISSY.add(&quot;html-parser/nodes/node&quot;, function (S) {

    function lineCount(str) {
        var i = 0;
        str.replace(/\n/g, function () {
            i++;
        });
        return i;
    }

<span id='KISSY-HtmlParse-Node'>    /**
</span>     * node structure from htmlparser
     * @param page
     * @param startPosition
     * @param endPosition
     * @class KISSY.HtmlParse.Node
     */
    function Node(page, startPosition, endPosition) {
        this.parentNode = null;
        this.page = page;
        this.startPosition = startPosition;
        this.endPosition = endPosition;
        this.nodeName = null;
        this.previousSibling = null;
        this.nextSibling = null;
        if (page) {
            this.startLine = lineCount(this.page.getText(0, startPosition));
            this.endLine = lineCount(this.page.getText(0, endPosition));
        }
        if (S.Config.debug) {
            this.toHTMLContent = this.toHtml();
        }
    }

    Node.prototype = {

        constructor: Node,

<span id='KISSY-HtmlParse-Node-method-toHtml'>        /**
</span>         * get outerHtml of current node
         * @returns {String}
         */
        toHtml: function () {
            if (this.page &amp;&amp; this.page.getText) {
                return this.page.getText(this.startPosition, this.endPosition);
            }
            return '';
        },

        toString: function () {
            var ret = [],
                self = this;
            ret.push(self.nodeName +
                &quot;  [ &quot; + self.startPosition + &quot;|&quot; +
                self.startLine +
                &quot; : &quot; + self.endPosition +
                &quot;|&quot; + self.endLine +
                &quot; ]\n&quot;);
            ret.push(self.toHtml());
            return ret.join(&quot;&quot;);
        }
    };

    return Node;
});</pre>
</body>
</html>
